package com.heaton.videocar.ui

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.tabs.TabLayoutMediator
import com.heaton.baselib.base.BaseActivity
import com.heaton.videocar.R
import kotlinx.android.synthetic.main.activity_input.*
import kotlinx.android.synthetic.main.title_layout.*

/**
 * author: jerry
 * date: 20-12-8
 * email: superliu0911@gmail.com
 * des:
 */
class InputActivity: BaseActivity() {
    override fun layoutId() = R.layout.activity_input

    private val tabs = listOf("工程信息", "管道属性", "管道参数")


    override fun bindData() {
        tv_title.text = "录入"
        tv_right.text = "保存"
        initViewpager()
    }

    override fun bindListener() {
        super.bindListener()
        iv_back.setOnClickListener { finish() }

    }

    private fun initViewpager() {
        viewpager.adapter = object : FragmentStateAdapter(this) {
            override fun getItemCount() = 3

            override fun createFragment(position: Int): Fragment {
                return when (position) {
//                    0 -> TextAttrFragment()
//                    1 -> TextEffectFragment()
                    else -> CoolFragment()
                }
            }
        }
        viewpager.offscreenPageLimit = 3
        TabLayoutMediator(tabLayout, viewpager) { tab, position ->
            tab.text = tabs[position]
        }.attach()
    }
}